package model

import business.Attackable
import business.Blockable
import business.Sufferable
import org.itheima.kotlin.game.core.Composer
import org.itheima.kotlin.game.core.Painter
import business.Destoryable

/**
 * 铁墙
 *
 * 阻塞的能力
 * 接受攻击的能力
 * 销毁的能力
 * */
class Steel(override var x: Int, override var y: Int) :Blockable,Sufferable, Destoryable {

    override val width: Int=GameConfig.SMALL_BLOCK_WIDTH
    override val height: Int=GameConfig.SMALL_BLOCK_WIDTH

    override var pool: Int=4

    override fun draw() {
        Painter.drawImage("img/steel_small.gif",x,y)
    }

    override fun notifySuffer(attack: Attackable): ArrayList<IView> {
        var list=ArrayList<IView>()
//        list.add(Blast(x,y))
        attack as Bullet

        /** 掉血*/
        if((attack.gradle==2)and (attack.ower is MyTank)){
            pool-=attack.power
        }

//        println("attack.gradle=${attack.gradle}")

        if(attack.ower is MyTank){ //我方坦克攻擊墻是播放聲音
            //播放子弹打墙的声音
            Composer.play("snd/hit.wav")
        }
        return list
    }

    override fun isDestory(): Boolean {
        return pool<=0
    }
}